import {Map,List,fromJS} from 'immutable';

export default (state = Map(), action) => {

  if (action.type === 'post_list') {
    return state.merge({
      posttype : action.posttype,
      pagination : fromJS(action.pagination),
      postlist : List(action.postlist)
    });
  }

  if (action.type === 'post_delete') {
    return state.update('postlist',value=>{
      return value.delete(action.index)
    });
  }

  if (action.type === 'post_detail') {
    return state.set('postdetail',action.detail);
  }

  return state;
};